<template>
  <div class="tabbar-item" @click="itemclick">
    <div v-if="!isActive">
      <slot name="item-img"></slot>
    </div>
    <div v-else>
      <slot name="item-img-active"></slot>
    </div>
    <div :class="{active:isActive}">
      <slot name="item-text"></slot>
    </div>
  </div>
</template>

<script>
export default {
  // data(){
  //   return {
  //     isactive: false
  //   }
  // }  
  props: {
    path: {
      type: String
    }
  },
  computed: {
    isActive(){
      return this.$route.path.indexOf(this.path) !== -1
    }
  },
  methods: {
    itemclick(){
      // console.log('1')
      this.$router.replace(this.path)
    }
  }
}
</script>

<style scoped>
  
.tabbar-item {
  flex: 1;
  text-align: center;
  font-size: 12px;
  font-weight: 600;
  color: blueviolet;
}

.tabbar-item img {
  width: 24px;
  height: 24px;
  display: block;
  margin: 5px auto 0;
}

.active {
  color: deeppink;
}
</style>